package com.itheima.boottlias.config;

import com.itheima.boottlias.interceptors.AuthorizedInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author ghy
 * @version 1.0
 * @since 2025-07-17 15:47
 */
@Configuration   //表示当前类是一个Spring的配置类
public class WebConfig implements WebMvcConfigurer {

    // @Autowired
    // private DemoInterceptor demoInterceptor;

    @Autowired
    private AuthorizedInterceptor authorizedInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // registry.addInterceptor(demoInterceptor)
         //       .addPathPatterns("/**");
        registry.addInterceptor(authorizedInterceptor)
                .excludePathPatterns("/login")
                .addPathPatterns("/**");
    }
}
